package com.mail.manager.modular.service.impl.portal;

import com.mail.manager.common.node.ZTreeNode;
import com.mail.manager.modular.mapper.ProductCategoryMapper;
import com.mail.manager.modular.model.ProductCategory;
import com.mail.manager.modular.service.portal.IProductCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 创建人： Shi Heng
 * 创建时间：2018-04-03 19:08
 * QQ：374696376
 * Description：
 */
@Service
public class ProductCategoryServiceImpl implements IProductCategoryService {

    @Resource
    ProductCategoryMapper categoryMapper;

    @Override
    public ProductCategory selectByPrimaryKey(Object id) {
        return categoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Map<String, Object>> list(String condition) {
        return categoryMapper.list(condition);
    }

    @Override
    public boolean insert(ProductCategory category) {
        Integer insert = categoryMapper.insert(category);
        if(insert>0)
            return true;
        return false;
    }

    @Override
    public List<ZTreeNode> tree() {
        return categoryMapper.tree();
    }

    @Override
    public boolean delteObject(Integer id) {
        int delete = categoryMapper.deleteByPrimaryKey(id);
        if(delete>0)
            return true;
        return false;
    }

    @Override
    public boolean updateObjtById(ProductCategory category) {
        int update = categoryMapper.updateByPrimaryKey(category);
        if(update>0)
            return true;
        return false;
    }
}
